|
|
|
|
|
|
|
In this line, column represents the name of the column in the requested data table, and value represents a literal value such as NY or Smith. It is important to know that the WHERE clause is always preceded by a SELECT_FROM statement. Use Visdata to enter and execute the following SQL statement, and compare your results to those in Figure 8.6. |
|
|
|
|
|
|
|
|
SELECT Name, StateProv FROM Publishers
WHERE StateProv = 'CA' |
|
|
|
|
|
|
|
|
Figure 8.6.
The results of a simple WHERE clause SQL query. |
|
|
|
|
| |
|
|
|
|
This book uses single quotation marks (') around string literals within SQL statements. Visual Basic SQL accepts both single and double quotation marks within SQL. Because you will often be building SQL statements in Visual Basic code, using single quotation marks within SQL statements makes it easier to construct and maintain SQL statements as Visual Basic strings. |
|
|
|
|
|
|
|
|
|
|
The previous SQL statement returns a subset of the data in the result set. That is, the resulting view does not contain all of the rows of the Publishers table. Only those rows that have columns meeting the WHERE clause criteria are returned in the result set. |
|
|
|
|
|
|
|
|
You can link WHERE clauses using the AND and OR operators. Enter and execute the following SQL statement, and compare your results to Figure 8.7. |
|
|
|
|
|
|
|
|
SELECT Name, StateProv, City FROM Publishers
WHERE StateProv = 'CA' AND City <> 'Senoma' |
|
|
|
|
|